package com.heying.springcore.aop.transaction;

import com.heying.springcore.SpringConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.sql.SQLException;

public class Test {

    public static void main(String[] args) throws SQLException {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(SpringConfig.class);

        UserService userService = context.getBean(UserService.class);
        UserInfo user1 = new UserInfo(1,"aaa");
        UserInfo user2 = new UserInfo(2,"bbb");

        new Thread(()->{
            try {
                userService.addTwoUsers(user1, user2);
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }).start();
        new Thread(()->{
            try {
                userService.addTwoUsers(user1, user2);
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }).start();

    }
}
